package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-09-11
 * Time: 13:41
 */
//用lambda表达式
public class demo8 {
    public static void main(String[] args) {
        Thread t=new Thread(()->{
            while(true){
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

        },"这是我的线程");
        t.start();//启动线程
        //查看线程API
        System.out.println(t.getId());//线程Id
        System.out.println(t.getName());//线程名称
        System.out.println(t.getPriority());//线程优先级
        System.out.println(t.getState());//状态
        System.out.println(t.isAlive());//是否存在
        System.out.println(t.isDaemon());//是否是后台线程
        System.out.println(t.isInterrupted());//是否被中断


    }
}
